//
//  OrderModel.m
//  JiFengDaRen
//
//  Created by zhuchao on 16/2/15.
//  Copyright © 2016年 SH_iOS. All rights reserved.
//

#import "OrderModel.h"
#import "ShoppingCartItemsModel.h"
#import "StoreModel.h"
@implementation OrderModel
-(NSArray *)shoppingcartitems{
     NSMutableArray *arr = [NSMutableArray arrayWithCapacity:0];
    if (_shoppingcartitems.count != 0) {
//       	icon = /res/upload/product_pics/%E5%8E%A8%E6%88%BF%E9%99%A4%E6%B8%8D720700.png,
//        quantity = 1,
//        product_name = 厨房清洁剂,
//        goods_type_name = ,
//        unit = 瓶,
//        product_id = 20,
//        price = 35
        for (NSDictionary *dict in _shoppingcartitems) {
            if ([dict[@"goods_type_name"] length] != 0 && [[NSString stringWithFormat:@"%@",dict[@"price"]] length] != 0) {
                ShoppingCartItemsModel *model = [[ShoppingCartItemsModel alloc]init];
                [model setValuesForKeysWithDictionary:dict];
                [arr addObject:model];
            }else if([dict[@"goods_type_name"] length] == 0 ){
                ShoppingCartItemsModel *model = [[ShoppingCartItemsModel alloc]init];
                model.icon = dict[@"icon"];
                model.quantity = [dict[@"quantity"] intValue];
                model.product_name = @"";
                model.product_id = [dict[@"product_id"] intValue];
                model.price = [dict[@"price"] floatValue];
                [arr addObject:model];
            }else if ([[NSString stringWithFormat:@"%@",dict[@"price"]] length] == 0){
                ShoppingCartItemsModel *model = [[ShoppingCartItemsModel alloc]init];
                model.icon = dict[@"icon"];
                model.quantity = [dict[@"quantity"] intValue];
                model.product_name = dict[@"product_name"];
                model.product_id = [dict[@"product_id"] intValue];
                model.price = 0;
                [arr addObject:model];
        }

    }
    }
    
    
    return arr;
}
-(StoreModel *)storeModel{
    
    StoreModel *model = [[StoreModel alloc]init];
    [model setValuesForKeysWithDictionary:_store];
    return model;
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}
@end
